{% extends "base.html" %}

{% block title %}浏览FTP目录{% endblock %}

{% block content %}
<div class="container mt-4">
    <h2>FTP目录浏览</h2>
    
    <!-- 面包屑导航 -->
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{{ url_for('browse_ftp', dir_id=dir_id) }}">根目录</a></li>
            {% if current_path %}
                {% set path_parts = current_path.split('/') %}
                {% set accumulated_path = '' %}
                {% for part in path_parts %}
                    {% if part %}
                        {% set accumulated_path = accumulated_path + '/' + part if accumulated_path else part %}
                        <li class="breadcrumb-item">
                            <a href="{{ url_for('browse_ftp', dir_id=dir_id, subpath=accumulated_path) }}">{{ part }}</a>
                        </li>
                    {% endif %}
                {% endfor %}
            {% endif %}
        </ol>
    </nav>

    <!-- 文件列表 -->
    <div class="table-responsive">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>名称</th>
                    <th>大小</th>
                    <th>修改时间</th>
                </tr>
            </thead>
            <tbody>
                {% for entry in entries %}
                <tr>
                    <td>
                        {% if entry.is_dir %}
                            <i class="fas fa-folder text-warning"></i>
                            <a href="{{ url_for('browse_ftp', dir_id=dir_id, subpath=entry.path) }}">{{ entry.name }}</a>
                        {% else %}
                            <i class="fas fa-file text-secondary"></i>
                            {{ entry.name }}
                        {% endif %}
                    </td>
                    <td>{{ entry.size }}</td>
                    <td>{{ entry.datetime }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

    <!-- 返回按钮 -->
    <div class="mt-3">
        <a href="{{ url_for('dashboard') }}" class="btn btn-secondary">返回仪表板</a>
    </div>
</div>

<style>
.container {
    margin-top: 2rem;
}
.table {
    margin-top: 1rem;
    margin-bottom: 2rem;
}
</style>
{% endblock %}